#pragma once

#include "ModelessDialog.h"

// FullQuoteDlg dialog

class FullQuoteDlg : public CModelessDialog, public L_Observer
{
	DECLARE_DYNAMIC(FullQuoteDlg)

public:
	enum L2_DISP_SIDE {
		DISP_BID,
		DISP_ASK
	};

	enum L2_DISP {
		DISP_MERGED,
		DISP_L2_NASDAQ,
		DISP_L2_NATIONAL,
		DISP_ECN
	};

public:
	FullQuoteDlg(CWnd* pParent = NULL);   // standard constructor
	virtual ~FullQuoteDlg();

	virtual BOOL Create(CWnd *pParentWnd = CWnd::FromHandle(L_GetMainWnd()));

// Dialog Data
	enum { IDD = IDD_FULLQUOTEDLG };

protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

	DECLARE_MESSAGE_MAP()

protected:
// L_Observer
	virtual void HandleMessage(L_Message const *pMsg);

private:
	//Controls
	CEdit m_SymbolEdit;
	CListCtrl m_FQDataListCtrl;
	CListCtrl m_BookListCtrl;
	CListCtrl m_TradesListCtrl;
	CComboBox m_BookSideCombo;
	CComboBox m_MarketCombo;
	CComboBox m_BookDispCombo;

	//Ctrl Helpers
	void ResizeControls();
	CString GetTextForFunction(int function);
	void InitializeDataCtrlRows();
	void UpdateStaticFQData();
	void UpdateL1FQData();	//Values that change on L1Update Msgs
	void UpdateL2FQData();	//values that change on L2Update Msgs
	void UpdateBook();		//updates the book data
	void UpdateBestQuotes();	//updates the best quotes data
	void UpdateListCtrlCellText(CListCtrl &ctrl, int nItem, int nSubItem, CString updateText);	//updates a cell of a CListCtrl
	void UpdateMarketComboBox();
	void InsertInitialTrades(); //will put the initial list of trades in the list
	void InsertNewTrade(double price, long long volume, char const *market, char saleCondition, time_t time);	//will insert new trades as the messages are recieved
	void SetSymbol(const char *symbol);

	char APIFunctions[64][32];
	void SetAPIFunctions();
	int m_iNextTradeRow;

	//data
	L_FullQuote *fullQuote;
	const L_Quote *bestQuote;
	const L_Quote *bestL2Quote;
	const L_Quote *bestECNQuote;

	//options
	int m_BookSideDisp;
	CString bestQuoteMarket;
	int m_BookDisp;
	bool m_Linked;

public:
	virtual BOOL OnInitDialog();
	virtual void OnOK();
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void OnCbnSelchangeBookSideCombo();
	afx_msg void OnCbnSelchangeMarketCombo();
	afx_msg void OnCbnSelchangeBookDispCombo();
	afx_msg void OnFileLink();
};
